package com.egene.tw.activity.product;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.egene.tw.R;
import com.egene.tw.base.BaseActivity;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

@EActivity(R.layout.activity_category_list)
public class CategoryListActivity extends BaseActivity {
    public static final String ID = "cid";
    public static final String NAME = "name";
    //ToolBar Views
    @ViewById(R.id.actionBar)
    Toolbar mToolbarView;
    @ViewById(R.id.toolbar_title)
    TextView mToolBarTitle;


    @AfterViews
    void initViews(){
        initToolBar();

        initFragment();
    }

    private void initToolBar() {
        mToolBarTitle.setText(getString(getIntent().getIntExtra(NAME,0))+  getString(R.string.single_item));
        mToolbarView.setNavigationIcon(R.drawable.ic_back);
        mToolbarView.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void initFragment() {
        Bundle bundle = new Bundle();
        bundle.putString(CategoryListFragment.ID, "" + getIntent().getIntExtra(ID,0));

        Fragment fragment = new CategoryListFragment_();
        fragment.setArguments(bundle);

        FragmentManager fragmentManager = getSupportFragmentManager();
        fragmentManager.beginTransaction().replace(R.id.rlContainer, fragment).commit();
    }


}
